import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
    providedIn: 'root'
})
export class WebStorageService {
    constructor(private _http: HttpClient) {}


    getHost(): string {
        return localStorage.getItem('host');
    }

    getToken(): string {
        return localStorage.getItem('token');
    }

    setToken(value: string) {
        localStorage.setItem('token', value);
    }

    getTags(): any {
        return JSON.parse(localStorage.getItem('tags'));
    }

    setTags(value: any) {
        localStorage.setItem('tags', JSON.stringify(value));
    }

    getTagsIndex(): number {
        return Number.parseFloat(localStorage.getItem('tagsIndex'));
    }

    setTagsIndex(value: number) {
        localStorage.setItem('tagsIndex', String(value));
    }

    clear() {
        this.setTagsIndex(null);
        this.setTags(null);
        this.setToken(null);
    }
}
